package com.tanger.im.event;

import com.tanger.im.IMUserRecordHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

/**
 * @Description IM事件监听
 * @Author Hchenbin
 * @Date 2023/12/29 17:35
 * @Version 1.0
 */
@Component
public class IMEventListener {

    Logger LOGGER = LoggerFactory.getLogger(getClass());


    /**
     * @Description @Async 异步操作 eventTraceExecutor 自定义线程池，提高线程利用率，执行效率
     * 事件可作为日志记录
     * @param e
     */
    @Async("eventTraceExecutor")
    @EventListener
    public void imEventListener(IMChatEvent e){
        IMUserRecordHelper.save(
                e.getSource(),
                e.getGroupId().toString(),
                e.getfId().toString(),
                e.gettId().toString());
    }
}
